package com.biz.primus.ms.order.convertor;

import com.biz.primus.model.order.vo.response.OrderSummaryResponseVO;
import com.biz.primus.ms.order.dao.po.OrderSummary;
import org.codelogger.utils.BeanUtils;

/**
 * 订单汇总转换器
 *
 * @author Tiger Feng
 * @date 2017年11月03日
 */
public class OrderSummaryConvertor {
    public static OrderSummary respVO2PO(OrderSummaryResponseVO vo) {
        if (vo == null) {
            return null;
        }
        OrderSummary po = new OrderSummary();
        BeanUtils.copyProperties(vo, po);
        po.setConsignee(OrderConsigneeInfoConvertor.vo2PO(vo.getConsignee()));
        po.setStoreOrder(
                OrderConvertor.respVO2PO(
                        vo.getStoreOrder(),
                        vo.getUserId(),
                        vo.getDepotCode(),
                        vo.getOrderIp(),
                        po.getConsignee(),
                        vo.getPromotion()
                )
        );
        po.setFlagshipOrder(
                OrderConvertor.respVO2PO(
                        vo.getFlagshipOrder(),
                        vo.getUserId(),
                        vo.getDepotCode(),
                        vo.getOrderIp(),
                        po.getConsignee(),
                        vo.getPromotion()
                )
        );
        return po;
    }

    public static OrderSummaryResponseVO po2RespVO(OrderSummary po) {
        if (po == null) {
            return null;
        }
        OrderSummaryResponseVO vo = new OrderSummaryResponseVO();
        BeanUtils.copyProperties(po, vo);
        vo.setConsignee(OrderConsigneeInfoConvertor.po2VO(po.getConsignee()));
        return vo;
    }
}
